package org.wei.rssreader;


import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;

public class RssUtil {

	/**
	 * 抓取SyndFeed,
	 * @param feedUrl
	 * @return 正常解析返回对象，否则返回null
	 */
	public static SyndFeed fatchByUrl(URL feedUrl){
		SyndFeedInput input = new SyndFeedInput();
		try {
			return input.build(new InputStreamReader(feedUrl.openStream()));
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public static void main(String[] args) {
		try {
			SyndFeed fatchByUrl = fatchByUrl(new URL("http://blog.sina.com.cn/rss/1191258123.xml") );
			System.out.println(fatchByUrl);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}





